const request = require('utils/request.js'), util = require('utils/util.js');
App({
    onLaunch(){},
    request: request,
    util: util,
    /*全局*/
    globalData: {
        userInfo: null,
    },
    /*判断内存有无登录*/
    Getinto: function () {
        util.showLoading('请稍候');
        this.globalData.my = this.Transfer({ name: 'fyzs_info' });
        this.globalData.brand = this.Transfer({ name: 'fyzs_brand' });
        if (this.globalData.my) {
            util.Success('登录成功', () => {
                request.must.merchant_id = this.globalData.my.merchant_id;
                setTimeout(() => {
                    wx.reLaunch({
                        url: '/pages/index/index'
                    })
                }, 1500)
            });
        } else {
            setTimeout(() => {
                wx.hideLoading();
            }, 1500)
        }
    },
    /*存取内存*/
    Transfer: function ({ name: el, info: val}) {
        let key = wx.getStorageSync(el) ? wx.getStorageSync(el) : val;
        if (val) {
            wx.setStorage({
                key: el,
                data: val,
            })
            return val;
        }
        return key;
    },
})